import {BaseModel} from "../BaseModel";

export class Downloaded extends BaseModel{

    constructor(){
        super();
        this.symbolName = "Downloader";
        this.tableName = "t_download_complete";
        this.id = '';//主键id,下载任务的taskId,即lessonId
        this.downloadedJson = '';//下载完成的描述json
        this.completeTime = '';//完成时间
        this.userId = '';//用户id
        this.reverse1 = '';//备用字段1  动作的状态：0 - 下载；1 - 更新；2 - 同步
        this.reverse2 = '';//备用字段2
        this.reverse3 = '';//备用字段3
    }

    dbMapper(){
        return {
            id: 'id',
            downloadedJson: 'downloaded_json',
            completeTime: 'complete_time',
            userId: "user_id",
            reverse1: 'reverse1',
            reverse2: 'reverse2',
            reverse3: 'reverse3'
        }
    }

    /**
     * 输出转换
     * @param obj
     * @returns {Book}
     */
    mappingModel(obj){
        let downloaded = new Downloaded();
        downloaded.id = obj.id ? obj.id : ''
        downloaded.downloadedJson = obj.downloaded_json ? obj.downloaded_json : ''
        downloaded.completeTime = obj.complete_time ? obj.complete_time : ''
        downloaded.userId = obj.user_id ? obj.user_id : ''
        downloaded.reverse1 = obj.reverse1 ? obj.reverse1 : ''
        downloaded.reverse2 = obj.reverse2 ? obj.reverse2 : ''
        downloaded.reverse3 = obj.reverse3 ? obj.reverse3 : ''
        return downloaded;
    }
}
